package com.scnu.gateway.client;

import com.scnu.common.result.Result;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.web.reactive.function.client.WebClient;
import reactor.core.publisher.Mono;

import java.time.LocalDateTime;

@Service
@RequiredArgsConstructor
public class UserService {

    private final WebClient.Builder webClientBuilder;

    public Mono<Result> getUserLogoutTime(Long userId) {
        Mono<Result> resultMono = webClientBuilder.build()
                .get()//GET请求
                .uri("http://rc-user/user/logout-time?userId={userId}", userId)
                .retrieve()// 发送请求并开始处理响应
                .bodyToMono(Result.class);//将响应体转换为 Mono<LocalDateTime>

        return resultMono;


    }
}
